#include <gtest/gtest.h>
#include <thread>
#include <logger/logger.h>
#include "scheduler/fallback_scheduler.h"
#include "../sample/navigation_task.h"
#include "../sample/battery_level_check.h"
#include "../sample/screen_return_zero_check.h"
#include "scheduler/scheduler_factory.h"

TEST(test_backfall_scheduler_demo, test_fallback_scheduler)
{
    auto navigation_task = task::TaskFactory<NavigationTask>::createTask("navigation_task");
    auto battery_level_check = task::TaskFactory<BatteryLevelCheck>::createTask("battery_level_check");
    auto screen_return_zero_check = task::TaskFactory<ScreenReturnZeroCheck>::createTask("screen_return_zero_check");

    auto navigation_scheduler = scheduler::SchedulerFactory<scheduler::FallbackScheduler>::createScheduler("navigation_scheduler");

    navigation_scheduler->appendTask(screen_return_zero_check);
    navigation_scheduler->appendTask(battery_level_check);
    navigation_scheduler->appendTask(navigation_task);

//    std::thread([&navigation_scheduler]
//                {
//                    usleep(9000);
//                    EASE_INFO("pause...");
//                    navigation_scheduler->pause();
//                    sleep(10);
//                    EASE_INFO("resume...");
//                    navigation_scheduler->resume();
//                }).detach();

    navigation_scheduler->run();

    EASE_INFO("done");
}
